package android.slc.appbase.repository.local.config;


import android.slc.db.sp.DataPersistence;
import android.slc.db.sp.DbCd;
import android.slc.db.sp.DpManager;

public class AppConfig extends DpManager {
    private static class Holder {
        private static final AppConfig INSTANCE = new AppConfig();
    }

    public static AppConfig getInstance() {
        return Holder.INSTANCE;
    }

    public static void init(int versionCode, String versionName, boolean isRelease) {
        if (appConfigIsInit) {
            return;
        }
        appConfigIsInit = true;
        getInstance().isRelease = isRelease;
        getInstance().dp
                .putIfAbsent("isRelease", getInstance().isRelease, false)
                .putIfAbsent("mockMode", false, true);
    }
    private boolean isRelease = true;
    private static boolean appConfigIsInit = false;

    private AppConfig() {
        super("app_config");
    }

    @Override
    protected DataPersistence<?> createDp(String dpName) {
        return new DbCd(dpName);
    }

    public boolean isRelease() {
        return dp.getBoolean("isRelease");
    }

    public boolean isMockMode() {
        return dp.getBoolean("mockMode");
    }

    public void setMockMoe(boolean mockMode) {
        dp.putValue("mockMode", mockMode);
    }
}
